package filter;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

public class HandlerChgInfo extends Handler {

	HandlerChgInfo(Filter filter) {
		super(filter);
	}

	@Override
	public void doCmd(String path) throws Exception {
		if(!(path.split(" ").length == 1)) {
			this.cmdError();
			throw new IOException(ErrorMessage);
		}
		
		if(new File(path).exists()) {
			filtOperation.chgFileProp(path);
		} else {
			this.fileError();
			throw new FileNotFoundException(ErrorMessage);
		}
	}
	
	@Override
	public void doTips() {
		System.out.println("Format : -chg [path]	\n"
				+ "	For change the attribute of the file exists in path\n "
				+ "	Change in 3 aspects : [name, ?readonly, ?hidden]");
	}

}
